/*
 * This file is part of the Sx Framework Library.
 * 
 * Copyright (C) 2013 University of Colorado Denver
 * <min.choi@ucdenver.edu> <shane.transue@ucdenver.edu>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy 
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 * copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 */
#ifndef SX_BUFFER_UTILITIES
#define SX_BUFFER_UTILITIES

#include <sxMath.h>
#include <sxArrayList.h>
#include <sxColor3.h>
#include <sxColor4.h>
#include <sxIndiceFace.h>

/*
 * Buffer Utilities are utilized to store and manipulate basic geometric 
 * information stored in contiguous arrays.
 */
namespace Sx {
namespace Graphics {
namespace Util {

using Sx::Util::ArrayList;

/*
 * A face array stores a set of indexed faces. Each face has a set of indices
 * that reference a vector that defines the boundary of the face.
 */
typedef ArrayList<Primitives::IndiceFace> IndexedFaceArray;

typedef ArrayList<Eigen::Matrix4f, Eigen::aligned_allocator<Eigen::Matrix4f> > TransformationArray;

/*
 * An IndexArray is used to store a list of indices that are used to
 * represent geometric primitives such as triangle lists.
 */
typedef ArrayList<unsigned int> IndexArray;

/*
 * A VectorArray is used to store an array of vector components. As per the
 * Eigen documentation the Eigen aligned allocator is used to ensure that
 * allocations will be properly aligned (this is not required for ever type
 * but it will be implemented as such).
 */
typedef ArrayList<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > VectorArray;

/*
 * A vector array that stores color information. As per the
 * Eigen documentation the Eigen aligned allocator is used to ensure that
 * allocations will be properly aligned (this is not required for ever type
 * but it will be implemented as such).
 */
typedef ArrayList<Color3f> ColorArray;

/*
 * A vector array that stores texture coordinates. As per the
 * Eigen documentation the Eigen aligned allocator is used to ensure that
 * allocations will be properly aligned (this is not required for ever type
 * but it will be implemented as such).
 */
typedef ArrayList<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > TextureCoordinateArray;

/*
 * A vector array that stores normals. As per the
 * Eigen documentation the Eigen aligned allocator is used to ensure that
 * allocations will be properly aligned (this is not required for ever type
 * but it will be implemented as such).
 */
typedef ArrayList<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > NormalArray;

/*
 * Given an array containing a set of vectors, each individual vector is
 * inversed inplace. If the vector is empty the function will return false;
 * otherwise it will return true indicating that the vectors in the array
 * were inversed.
 */
bool Inverse(VectorArray& v);

/*
 * Copies the contiguous set of vectors from the source array to the
 * destination array.
 */
void Copy(VectorArray& destination, const VectorArray& source);
void Copy(ColorArray& destination, const ColorArray& source);
 
}

}

}

#endif
